package com.nuanshui.heatedloan.entity.cms.security;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nuanshui.heatedloan.entity.IdEntity;

/**
 * 用户与角色的中间表
 */
@Entity
@Table(name = "cms_security_user_role")
public class UserRole extends IdEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 值越小，优先级越高，不过暂时还没什么用哦
	 */
	@Column(length = 2, nullable = false)
	private Integer priority = 99;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "roleId")
	private Role role;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userId")
	private User user;

	/**
	 * 返回 role 的值
	 * 
	 * @return role
	 */
	public Role getRole() {
		return role;
	}

	/**
	 * 设置 role 的值
	 * 
	 * @param role
	 */
	public void setRole(final Role role) {
		this.role = role;
	}

	/**
	 * 返回 user 的值
	 * 
	 * @return user
	 */
	@JsonIgnore
	@JSONField(serialize=false)
	public User getUser() {
		return user;
	}

	/**
	 * 设置 user 的值
	 * 
	 * @param user
	 */
	public void setUser(final User user) {
		this.user = user;
	}

	/**
	 * 返回 priority 的值
	 * 
	 * @return priority
	 */
	public Integer getPriority() {
		return priority;
	}

	/**
	 * 设置 priority 的值
	 * 
	 * @param priority
	 */
	public void setPriority(final Integer priority) {
		this.priority = priority;
	}

}
